package com.xayy.mgt.controller;

import cn.kawins.base.result.ResultBody;
import cn.kawins.mybatis.base.BaseController;
import com.xayy.mgt.model.HealthSituation;
import com.xayy.mgt.model.vo.EvaluationVo;
import com.xayy.mgt.model.vo.WordReportVo;
import com.xayy.mgt.service.HealthSituationService;
import com.xayy.mgt.service.NodeInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @author Nie
 * @version V1.0
 * @date 2023/8/17 11:41
 */
@RestController
@RequestMapping(value = "/healthSituation1")
@Api(tags = "单星健康态势")
public class HealthSituationController extends BaseController<HealthSituation> {
    @Autowired
    private HealthSituationService healthSituationService;

    @Autowired
    private NodeInfoService nodeInfoService;

    @PostMapping("/evaluation")
    @ApiOperation(value = "节点健康评估", httpMethod = "POST")
    public ResultBody evaluation(@RequestBody EvaluationVo evaluationVo) {
        return healthSituationService.evaluation(evaluationVo).body();
    }

    @GetMapping("/getIndexCurveData/{nodeId}")
    @ApiOperation(value = "指标曲线图数据", httpMethod = "GET")
    public ResultBody getIndexCurveData(@PathVariable Long nodeId) {
        return healthSituationService.getIndexCurveData(nodeId).body();
    }

    @GetMapping("/getHealthDeepInfo/{nodeId}")
    @ApiOperation(value = "获取单星健康态势-右侧表单数据", httpMethod = "GET", notes = "获取单星健康态势-右侧表单数据")
    public ResultBody getHealthDeepInfo(@PathVariable Long nodeId) {
        return healthSituationService.getHealthDeepInfo(nodeId).body();
    }

    @GetMapping("/timeAxisData")
    @ApiOperation(value = "时间轴数据",httpMethod = "GET",response = ArrayList.class,notes = "单星健康态势-时间轴数据")
    public ResultBody timeAxisData(
            @Param("id") @RequestParam("id") String id,
            @Param("sDate") @RequestParam(value = "sDate",required = false) String sDate,
            @Param("eDate") @RequestParam(value = "eDate",required = false)  String eDate) {
        return ResultBody.success(nodeInfoService.timeAxisData(Long.parseLong(id),sDate,eDate));
    }

    @GetMapping("/generateHealthReport")
    @ApiOperation(value = "单星健康态势-生成健康报告", httpMethod = "GET", notes = "单星健康态势-生成健康报告")
    public ResultBody generateHealthReport(@RequestParam("nodeId") Long nodeId) {
        return healthSituationService.generateHealthReport(nodeId).body();
    }

    @PostMapping("/generateHealthReportForWord")
    @ApiOperation(value = "单星健康态势-生成健康报告-WORD", httpMethod = "POST", notes = "单星健康态势-生成健康报告-WORD")
    public void generateHealthReportForWord(@RequestBody WordReportVo wordReportVo) {
        healthSituationService.generateHealthReportForWord(wordReportVo);
    }

}
